Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow string type to be controlled from the public API #177

Merged
merged 7 commits into from
Feb 14, 2022

Conversation

abravalheri
Copy link
Contributor

@abravalheri abravalheri commented Feb 10, 2022

Hello, it would be interesting to expose a way of controlling the string style (e.g. allowing multi line strings).

This PR is an attempt to provide such API.

I ended up going for a very verbose API (with explicit keywords) because I believe that it is easier to use, but please let me know if you prefer exposing StringType as part of the public API.

I think this closes #44.

@abravalheri abravalheri marked this pull request as ready for review February 10, 2022 19:06
tomlkit/api.py Outdated Show resolved Hide resolved
tomlkit/items.py Outdated Show resolved Hide resolved
@abravalheri
Copy link
Contributor Author

Thank you very much for the kind review @frostming.

I changed the implementation to address escaping properly trying to follow what the standard has to say about which characters and sequences that can or cannot appear in the string value...

(P.S.: I had one doubt about the standard text, so I opened this issue: toml-lang/toml#877)

Previously invalid chars were being escaped for the sake of not having
invalid strings.

It is preferable instead to explicitly fail.
Copy link
Contributor

@frostming frostming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your great work

@frostming frostming merged commit 781401e into python-poetry:master Feb 14, 2022
@abravalheri abravalheri deleted the add-api-for-strings branch February 14, 2022 01:51
capuanob pushed a commit to capuanob/tomlkit that referenced this pull request Mar 1, 2023
…ings

Allow string type to be controlled from the public API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiline dump?
2 participants